package com.enqualcomm.kids.activities;

import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.view.WindowManager;
import android.widget.RadioGroup;
import android.widget.TextView;

import com.enqualcomm.kids.BuildConfig;
import com.enqualcomm.kids.R;
import com.enqualcomm.kids.base.BaseActivity;
import com.enqualcomm.kids.config.userdefault.AppDefault;

public class NotifycationSettingActivity extends BaseActivity implements RadioGroup.OnCheckedChangeListener, View.OnClickListener {

    private AppDefault appDefault;
    private RadioGroup notify_detail_group;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_notifycation_setting);

        findViewById(R.id.title_bar_left_iv).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        TextView title_bar_name = (TextView) findViewById(R.id.title_bar_title_tv);
        title_bar_name.setText(R.string.notification_panel);

        TextView title_bar_terminal_name_tv = (TextView) findViewById(R.id.title_bar_terminal_name_tv);
        View title_bar_terminal_icon_iv = findViewById(R.id.title_bar_terminal_icon_iv);
        title_bar_terminal_icon_iv.setVisibility(View.GONE);
        title_bar_terminal_name_tv.setVisibility(View.VISIBLE);
        title_bar_terminal_name_tv.setText(getString(R.string.notification_panel));

        appDefault = new AppDefault();
        notify_detail_group = (RadioGroup) findViewById(R.id.notify_detail_group);
        initNotifyRadioGroup();
        notify_detail_group.setOnCheckedChangeListener(this);
        findViewById(R.id.wx_gg_rl).setOnClickListener(this);
        if (!"西瓜皮-西瓜皮".equals(BuildConfig.CHANNEL)) {
            findViewById(R.id.wx_gg_title_rl).setVisibility(View.GONE);
            findViewById(R.id.wx_gg_rl).setVisibility(View.GONE);
            findViewById(R.id.phone_notify_set_title_rl).setVisibility(View.GONE);
        }
    }

    private void initNotifyRadioGroup() {
        String notify_setting = appDefault.getNotifycationPref();
        int id = 0;
        switch (notify_setting) {
            case "1":
                id = R.id.notify_radioBtn1;
                break;
            case "2":
                id = R.id.notify_radioBtn2;
                break;
            case "3":
                id = R.id.notify_radioBtn3;
                break;
            case "4":
                id = R.id.notify_radioBtn4;
                break;

            default:
                break;
        }

        notify_detail_group.check(id);
    }

    @Override
    public void onCheckedChanged(RadioGroup group, int checkedId) {
        switch (checkedId) {
            case R.id.notify_radioBtn1:
                appDefault.setNotifycationPref("1");
                break;
            case R.id.notify_radioBtn2:
                appDefault.setNotifycationPref("2");
                break;
            case R.id.notify_radioBtn3:
                appDefault.setNotifycationPref("3");
                break;
            case R.id.notify_radioBtn4:
                appDefault.setNotifycationPref("4");
                break;
            default:
                break;
        }

    }

    void wxGGActivity() {
        startActivity(WXGGDisplayActivity_.class);
    }

    @Override
    public void onClick(View view) {
        int viewid = view.getId();
        switch (viewid) {
            case R.id.wx_gg_rl:
                wxGGActivity();
                break;
        }
    }
}
